package cn.hdustea.shopNavigation.widget

import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView

/**
 * <pre>
 * author : HuQiang
 * time   : 2020/09/19
 * desc   :
 * version: 1.0
</pre> *
 */
internal class SquareTextView : AppCompatTextView {
    constructor(context: Context) : super(context)
    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)

    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
        setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec))
        val childWidthSize = measuredWidth
        //高度和宽度一样
        width = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY)
        height = widthMeasureSpec
        super.onMeasure(width, height)
    }
}